<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>汽车衡称重系统</title>
	<link href="__STATIC__/css/common.css" rel="stylesheet">
	<link rel="stylesheet" href="__STATIC__/css/index.css">
	<link rel="stylesheet" type="text/css" href="__STATIC__/js/datetimepicker/jquery.datetimepicker.css"/>
	<style>
		.ms-controller{
			display:none;
		}
	</style>
	<script src="__STATIC__/js/LodopFuncs.js"></script>
	<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0> 
	  <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
	</object>
	
</head>
<body ms-controller="view" class="ms-controller" ms-visible="display_main">
	<div class="header">
		<div class="header-box">
			<ul class="menu-box">
				<li class="menu-item" ms-class="menu-active:menu_label == 'scale'" ms-click="changeMenu('scale')">称重</li>
				<li class="menu-item" ms-class="menu-active:menu_label == 'system'" ms-click="changeMenu('system')">系统维护</li>
				<li class="menu-item" ms-class="menu-active:menu_label == 'report'" ms-click="changeMenu('report')">统计报表</li>
				<li class="menu-item" ms-class="menu-active:menu_label == 'function'" ms-click="changeMenu('function')">财务核算</li>
				<li class="menu-item"><a style="color:blue;" target="_blank" href="/home/index/insertByHand">手动补单</a></li>
			</ul>
		</div>
	</div>
	<div class="main">
		<div class="main-report">
			<div class="report-box">
				<div style="width:99%;margin:0 auto;height:75px;padding-top:10px;padding-bottom:10px;border:1px solid #dedede;margin-bottom:10px;">
					<div class="select-box">
						<div style="width:100%;">
							<label class="function_input" style="width:14.5%;">磅房：
								<select  class="function_input" style="width:65%;height:30px;" ms-change="getNormalReport" ms-duplex="normal_search.houseId">
									<option value="">不限</option>
									<option ms-repeat-el="house_list" ms-attr-value="el.houseId">(|el.houseName|)</option>
								</select>
							</label>					
							<label class="function_input" style="width:18%;margin-left:3px;">开始日期：
								<input type="text" id="datetimepicker_dark_1" class="function_input" style="width:60%;" ms-change="getNormalReport" ms-duplex="normal_search.billDateStart">
							</label>
							<label class="function_input" style="width:18%;margin-left:3px;">结束日期：
								<input type="text" id="datetimepicker_dark_2" class="function_input" style="width:60%;" ms-change="getNormalReport" ms-duplex="normal_search.billDateEnd">
							</label>
							<label class="function_input" style="width:13.5%;margin-left:3px;">物资名称：
								<select  class="function_input" style="width:48%;height:30px;" ms-change="getNormalReport" ms-duplex="normal_search.goodsName">
									<option value="">不限</option>
									<option ms-repeat-el="goods_list" ms-attr-value="el.goodsName">(|el.goodsName|)</option>
								</select>
							</label>
							<label class="function_input" style="width:14.5%;margin-left:3px;">发货单位：
								<select  class="function_input" style="width:50%;height:30px;" ms-change="getNormalReport" ms-duplex="normal_search.sendUnit">
									<option value="">不限</option>
									<option ms-repeat-el="customer_receive_list" ms-attr-value="el.customerName">(|el.customerName|)</option>
								</select>
							</label>
							<label class="function_input" style="width:14.5%;margin-left:3px;">收货单位：
								<select  class="function_input" style="width:50%;height:30px;" ms-change="getNormalReport" ms-duplex="normal_search.receiveUnit">
									<option value="">不限</option>
									<option ms-repeat-el="customer_receive_list" ms-attr-value="el.customerName">(|el.customerName|)</option>
								</select>
							</label>
						</div>
						<div style="width:100%;padding:0;margin-top:13px;padding-top:1px;">
							<label class="function_input" style="width:13%;margin-left:3px !important;">操作员：
								<select  class="function_input" style="width:50%;height:30px;" ms-change="getNormalReport" ms-duplex="normal_search.fullOperator">
									<option value="">不限</option>
									<option ms-repeat-el="user_list" ms-attr-value="el.userName">(|el.userName|)</option>
								</select>
							</label>
							<label class="function_input" style="width:18%;height:30px !important;margin-left:3px;">磅单编号：
								<input type="text" class="function_input" style="display:inline-block;width:55%;height:20px;line-height:20px;" ms-change="getNormalReport" ms-duplex="normal_search.billCode">
							</label>
							<label class="function_input" style="width:13%;margin-left:3px;">车牌号码：
								<select  class="function_input" style="width:45%;height:30px;" ms-change="getNormalReport" ms-duplex="normal_search.truckCode">
									<option value="">不限</option>
									<option ms-repeat-el="truck_list" ms-attr-value="el.truckCode">(|el.truckCode|)</option>
								</select>
							</label>
							<label class="function_input" style="width:17.5%;margin-left:3px;">发货位置：
								<select  class="function_input" style="width:60%;height:30px;" ms-change="getNormalReport" ms-duplex="normal_search.position">
									<option value="">不限</option>
									<option ms-repeat-el="position_list" ms-attr-value="el.position">(|el.position|)</option>
								</select>
							</label>
							<label class="function_input" style="width:17.5%;margin-left:3px;">发运路线：
								<select  class="function_input" style="width:60%;height:30px;" ms-change="getNormalReport" ms-duplex="normal_search.route">
									<option value="">不限</option>
									<option ms-repeat-el="route_list" ms-attr-value="el.route">(|el.route|)</option>
								</select>
							</label>
							<label class="function_input" style="width:14%;margin-left:3px;">钩&nbsp;机&nbsp;号：
								<select  class="function_input" style="width:50%;height:30px;" ms-change="getNormalReport" ms-duplex="normal_search.excavator">
									<option value="">不限</option>
									<option ms-repeat-el="excavator_list" ms-attr-value="el.excavatorCode">(|el.excavatorCode|)</option>
								</select>
							</label>
						</div>
						
						
					</div>
					<div class="select-button-box">
						<button style="width:60px;height:30px;line-height:30px;background-color:#44B549;color:white;border-radius:4px;" >
							打印
						</button>
						<button style="width:60px;height:30px;line-height:30px;background-color:#44B549;color:white;border-radius:4px;margin-left:5px;" ms-click="exportNormalReport()">
							导出
						</button>
						<button style="width:60px;height:30px;line-height:30px;background-color:#44B549;color:white;border-radius:4px;" ms-click="changeAll(1)">
							全选
						</button>
						<br/>
						<br/>						
						<button style="width:60px;height:30px;line-height:30px;background-color:#44B549;color:white;border-radius:4px;" ms-click="changeAll(0)">
							全不选
						</button>
						<button style="width:60px;height:30px;line-height:30px;background-color:#44B549;color:white;border-radius:4px;margin-left:5px;" ms-click="changeMoreBillLocked(1)">
							批量审核
						</button>
						<button style="width:60px;height:30px;line-height:30px;background-color:red;color:white;border-radius:4px;margin-left:5px;" ms-click="changeMoreBillLocked(0)">
							批量解锁
						</button>
					</div>
					<!-- <button style="width:60px;height:30px;line-height:30px;background-color:#44B549;color:white;border-radius:4px;" ms-click="getNormalReport">刷新</button> -->
					
				</div>

				<div class="report_list_box" id="daily_report">
					<p style="margin-top:20px;text-align:center;font-size:16px;color:red;" ms-visible="normal_report_list.length <= 0">没有查到任何记录</p>
					<table class="report_list" border="1" cellspacing="0" ms-visible="normal_report_list.length > 0" style="font-size:14px;table-layout:fixed;border-collapse:collapse;">
						<thead>
						<tr>
							<td colspan="20" style="border:0px !important;height:0px;">
								<h3 style="font-size:20px;text-align:center;margin-top:-25px;" ms-text="config.company + '过磅单查询'"></h3>
							</td>
						</tr>
						<tr>
							<th>编号</th>
							<th>磅单编号</th>
							<th>过磅日期</th>
							<th>物资名称</th>
							<th>车牌号码</th>
							<th>司机姓名</th>
							<th>皮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;重</th>
							<th>检皮时间</th>
							<th>检皮人员</th>
							<th>毛&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;重</th>
							<th>检重时间</th>
							<th>检重人员</th>
							<th>净&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;重</th>
							<th>发货单位</th>
							<th>收货单位</th>
							<th>发货位置</th>
							<th>发运路线</th>
							<th>钩机号</th>
							<th>磅房名称</th>
							<th>车辆图片</th>
							<th>磅单状态</th>						
							<th>打印次数</th>
							<th>作废</th>							
							<th>审核</th>
						</tr>
						</thead>
						<tbody>					
						<tr ms-repeat-el="normal_report_list" ms-class="(|el.bg|)">
							<td><input type="checkbox" ms-attr-checked="el.selected" ms-click="clickbill($index)"></td>
							<td ms-text="el.billCode"></td>
							<td ms-text="el.billDateDesc"></td>
							<td ms-text="el.goodsName"></td>
							<td ms-text="el.truckCode"></td>
							<td ms-text="el.driver"></td>
							<td ms-text="el.emptyWeigh"></td>
							<td ms-text="el.emptyTimeDesc"></td>
							<td ms-text="el.emptyOperator"></td>
							<td ms-text="el.fullWeigh"></td>
							<td ms-text="el.fullTimeDesc"></td>
							<td ms-text="el.fullOperator"></td>
							<td ms-text="el.weigh"></td>
							<td ms-text="el.sendUnit"></td>
							<td ms-text="el.receiveUnit"></td>
							<td ms-text="el.position"></td>
							<td ms-text="el.route"></td>
							<td ms-text="el.excavator"></td>
							<td ms-text="el.houseName"></td>
							<td ms-mouseenter="showImg(el)" ms-mouseleave="hideImg">图片</td>
							<td>
								<span style="width:30px;height:20px;line-height:20px;color:#333333;" ms-visible="el.dataFlag == 1">正常</span>
								<span style="width:30px;height:20px;line-height:20px;color:white;background-color:red;" ms-visible="el.dataFlag == 0">作废</span>
							</td>
							<td ms-text="el.printCount"></td>
							<td style="padding-left:5px;padding-right:5px;">
								<button style="width:40px;height:20px;line-height:20px;color:white;background-color:red;" ms-click="delBill(el,1)" ms-visible="el.dataFlag == 1">作废</button>
								<button style="width:40px;height:20px;line-height:20px;color:white;background-color:green;" ms-click="delBill(el,5)" ms-visible="el.dataFlag == 0">回复</button>
							</td>						
							<td>								
								<button ms-visible="el.locked == 0" style="width:40px;height:20px;line-height:20px;color:white;background-color:green;" ms-click="changeBillLocked(el.billId,1)">审核</button>
								<button ms-visible="el.locked == 1" style="width:40px;height:20px;line-height:20px;color:white;background-color:red;" ms-click="changeBillLocked(el.billId,0)">解锁</button>
								</td>
						</tr>
						
						<tr>
							<td colspan="24" style="font-size:26px;height:60px;line-height:60px;" ms-text="'总车数为' + normal_report_cs + '车,有效车数为' + che_sum + '车' + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;总重量为' + normal_report_sum + '吨,有效重量为' + dun_sum + '吨'">
							</td>
						</tr>
						</tbody>
					</table>
					
				</div>
			</div>
		</div>
	</div>		
	<div class="mask_layer" ms-visible="login_box_display">
		<div class="form-box" style="padding-bottom:50px;border-radius:10px;">
			<h2 style="width:100%;text-align:center;margin-top:40px;">切换用户</h2>
			<select class="login-item" style="height:30px;" ms-duplex="user_login.userName">
				<option value="">请选择用户名</option>
				<option ms-repeat-el="user_list" ms-attr-value="el.userName">(|el.userName|)</option>
			</select>
			<input type="password" class="login-item" placeholder="密码" style="height:30px;" ms-duplex="user_login.userPwd" />
			<button id="submit" style="width:100px;height:40px;background-color:#44B549;color:white;border:1px solid #44B549;border-radius:5px;margin-top:30px;" ms-click="signin">登  录</button>
			<button id="submit" style="width:100px;height:40px;background-color:#44B549;color:white;border:1px solid #44B549;border-radius:5px;margin-top:30px;" ms-click="unSignin">取  消</button>
		</div>
	</div>
	<div class="mask_layer" ms-visible="lock_box_display">
		<div class="form-box" style="padding-bottom:50px;border-radius:10px;">
			<h2 style="width:100%;text-align:center;margin-top:40px;">解除屏幕锁定</h2>
			<input type="text" class="login-item" placeholder="用户名" style="height:30px;" ms-duplex="user_login.userName" readonly="true" />
			<input type="password" class="login-item" placeholder="密码" style="height:30px;" ms-duplex="user_login.userPwd" />
			<button id="submit" style="width:100px;height:40px;background-color:#44B549;color:white;border:1px solid #44B549;border-radius:5px;margin-top:30px;" ms-click="signin($event,1)">解除锁定</button>
		</div>
	</div>
	<div id="img-box" style="position:fixed;width:600px;height:337px;top:150px;margin:0 auto;border:1px solid #dedede;background-color:#333333;" ms-visible="pic_dis == true">
		<img ms-attr-src="pic_url" alt="" style="width:600px;">
	</div>
	<script src="__STATIC__/js/jquery.min.js"></script>
	<script src="__STATIC__/js/datetimepicker/build/jquery.datetimepicker.full.js"></script>
	<script src="__STATIC__/js/layer/layer.js"></script>
	<script src="__STATIC__/js/avalon.js"></script>
	<script src="__STATIC__/js/common.js"></script>
	<script src="__STATIC__/js/jquery.cookie.min.js"></script>
	<script src="__STATIC__/js/jQuery.md5.js"></script>
	<script src="__STATIC__/js/logic.js"></script>
	<script src="__STATIC__/js/validator.js"></script>
	<script src="__STATIC__/js/TComm-mini.js?t=2"></script>
	<script src="__STATIC__/js/print.js"></script>
	
	<script>
	jQuery(document).ready(function(){
		console.log(new Date().Format('yyyy-MM-dd'));
		avalon.config({
          interpolate : ["(|","|)"]
        });
       	
       	var w = $(document).width();
		var h = $(document).height();
		$("#img-box").css('left',(w - 600) / 2 + 'px').css('top',(h - 300) / 2 + 'px');
		$.datetimepicker.setLocale('ch');
		$('#datetimepicker_dark_1').datetimepicker(
			{
				/*theme:'dark',*/
				timepicker:true,
				format:'Y-m-d H:i',
				formatDate:'Y-m-d H:i',
				defaultTime:'00:00',
				defaultDate:new Date().Format('yyyy-MM-dd H:i'),
				onClose:function(){
					var td = $("#datetimepicker_dark_1").val();
					if(td != vm.normal_search.billDateStart){
						vm.normal_search.billDateStart = td;
						vm.getNormalReport();
					}
				}
			}
		);
		$('#datetimepicker_dark_2').datetimepicker(
			{
				/*theme:'dark',*/
				timepicker:true,
				format:'Y-m-d H:i',
				formatDate:'Y-m-d H:i',
				defaultTime:'00:00',
				defaultDate:new Date().Format('yyyy-MM-dd H:i'),
				onClose:function(){
					var td = $("#datetimepicker_dark_2").val();
					if(td != vm.normal_search.billDateEnd){
						vm.normal_search.billDateEnd = td;
						vm.getNormalReport();
					}
				}
			}
		);

        var vm = avalon.define({
        	$id : "view",
        	menu_label:'function',
        	display_main:true,
        	weigh_display_str:'weigh',
        	weigh_class:'weigh-red',
        	weigh:0,
        	che_sum:0,
        	dun_sum:0,
        	houseId:0,
        	houseName:'',
        	menu_sub:{scale:'full',system:'',report:'',function:''},
        	login_box_display:false,/*是否显示切换用户界面*/
        	lock_box_display:false,/*是否显示屏幕锁定界面*/
        	user_info:{},
        	user_list:[],
        	user_login:{userName:'',userPwd:'',error:false,msg:''},
        	house_list:[],
        	user_power:[],
        	config:{weighModel:0,codeType:0,codeLen:3,codePagearea:'',codePrintarea:''},
        	normal_report_list:[],
        	normal_report_sum:0,
        	normal_report_cs:0,
        	normal_search:{billDate:new Date().Format('yyyy-MM-dd'),goodsName:'',sendUnit:'',receiveUnit:'',fullOperator:'',houseId:'',timeArea:0,billDateStart:new Date().Format('yyyy-MM-dd h:m'),billDateEnd:new Date().Format('yyyy-MM-dd h:m'),billCode:'',truckCode:'',position:'',route:'',excavator:'',md:1},
        	goods_list:[],
        	truck_list:[],
        	customer_receive_list:[],
        	customer_list:[],
			route_list:[],
			position_list:[],
			excavator_list:[],
			pic_dis:false,
			pic_url:'',
			select_list:[],
        	load:function(){
        		$.post(logic_urls.index,{},
        			function(data,textStatus){
        				var json = TX.toJson(data);
        				var t = Date.parse(new Date()) / 1000;
        				if(Math.abs(t - json.time) >= 3000){
        					var tt = new Date(parseInt(json.time) * 1000).toLocaleString();
        					alert('当前系统与服务器时间不同步,服务器时间为:' + tt + ".请手动修改系统时间");
        					vm.display_main = false;
        					return;
        				}
        				for(var k in json.data){
        					vm[k] = json.data[k];
        				}
        				vm.user_power = vm.user_info.power.split(',');
        				avalon.scan();
        			}
        		);
        	},
        	changeMenu:function(m){
        		if(m == 'system'){
        			window.location.href = '/home/index/system';
        			return;
        		}
        		if(m == 'report'){
        			//window.location.href = '/home/index/report';
        			window.open('/home/index/report');
        			return;
        		}
        		if(m == 'function'){
        			window.location.href = '/home/index/accounting';
        			return;
        		}
        		vm.menu_label = m;
        		window.location.href = '/home/index/index';
        	},
        	getNormalReport:function(){
        		TX.msg('正在读取数据',{time:200000});
        		vm.normal_report_list = [];
        		vm.normal_report_sum = 0;
        		vm.normal_report_cs = 0;
        		vm.normal_search.timeArea = 1;
        		vm.normal_search.md = 1;
        		console.log(vm.normal_search);
        		$.post(logic_urls.getNormalReport,vm.normal_search,
        			function(data){
        				var json = TX.toJson(data);
        				console.log(json);
        				if(json.status == 1){
        					layer.closeAll();
        					vm.normal_report_list = [];
        					vm.normal_report_sum = json.sum;
        					vm.normal_report_cs = json.cs;
        					for(var i=0;i<json.data.length;i++){
        						var v = json.data[i];
        						v.selected = false;
        						vm.normal_report_list.push(v);
        					}
        					vm.countBill();
        					avalon.scan();
        				}else{
        					TX.msg(json.msg);
        				}
        			}
        		);
        	},
        	exportNormalReport:function(){
        		if(vm.normal_report_list.length <= 0){
        			TX.msg('没有可导出的内容',{time:3000});
        			return false;
        		}
        		var sk = '';
        		for(var k in vm.normal_search){
        			sk = sk + k + '=' + vm.normal_search[k] + '&';
        		}
        		sk = sk.substr(0,sk.length - 1);
        		console.log(sk);
        		window.open(logic_urls.exportNormalReport + '?' + sk);
        	},
        	showImg:function(el){
        		vm.pic_dis = true;
        		console.log(el);
        		//var tr = el.billCode.substr(0,10);
        		vm.pic_url = '/public/upload/' + vm.config.serverPicurl + el.picPath + '/' + el.picUrl;
        	},
        	hideImg:function(){
        		vm.pic_url = '';
        		vm.pic_dis = false;
        	},
        	clickbill:function(id){
        		console.log(this.checked);
        		vm.normal_report_list[id]['selected'] = this.checked;
        	},
        	changeAll:function(invi){
        		console.log(vm.normal_report_list.length);
        		var sk = false;
        		if(invi == 1){
        			sk = true;
        		}
        		for(var i=0;i<vm.normal_report_list.length;i++){
        			vm.normal_report_list[i]['selected'] = sk;
        		}
        	},
        	changeBillLocked:function(str,invi){
        		if(str.length == 0){
        			TX.msg('您还没有选择任何磅单',{time:3000});
        			return;
        		}
        		TX.msg('数据更新中，请稍后...',{time:30000});
        		$.post(logic_urls.changeBillLocked,{ids:str,locked:invi},
        			function(data){
        				var json = TX.toJson(data);
        				console.log(json);
        				layer.closeAll();
        				if(json.status == 1){
        					var ids = json.data.split(',');
        					console.log(ids);
        					var pd = json.type;
        					for(var i=0;i<vm.normal_report_list.length;i++){
        						for(var k=0;k<ids.length;k++){
        							if(vm.normal_report_list[i]['billId'] == ids[k]){
        								vm.normal_report_list[i]['locked'] = pd;
        								break;
        							}
        						}
        					}
        				}else{
        					TX.msg("更新数据失败，代码为：" + json.msg,{icon:1,time:3000});
        				}
        			}
        		);
        	},
        	changeMoreBillLocked:function(invi){
        		vm.select_list = [];
        		var ids = '';
        		for(var i=0;i<vm.normal_report_list.length;i++){
        			if(vm.normal_report_list[i]['selected']){
        				vm.select_list.push(vm.normal_report_list[i]['billId']);
        			}
        		}
        		if(vm.select_list.length == 0){
        			ids = '';
        		}else{
        			ids = vm.select_list.join(',');
        		}
        		if(ids.length == 0){
        			TX.msg('您还没有选择任何磅单',{time:3000});
        			return;
        		}
        		vm.changeBillLocked(ids,invi);
        	},
        	delBill:function(el,md){
        		var sd = {
        			billId:el.billId,
        			emptyWeigh:el.emptyWeigh,
        			fullWeigh:el.fullWeigh,
        			weigh:el.weigh,
        			md:md
        		};
        		TX.msg('正在保存数据',{time:5000});
        		$.post(logic_urls.delBill,sd,
        			function(data){
        				var json = TX.toJson(data);
        				if(json.status == 1){
        					console.log(json);
        					layer.closeAll();
        					for(var i=0;i<vm.normal_report_list.length;i++){
        						if(vm.normal_report_list[i].billId == json.data.billId){
        							if(sd.md == 1){
        								vm.normal_report_list[i]['dataFlag'] = 0;
        							}else if(sd.md == 5){
        								vm.normal_report_list[i]['dataFlag'] = 1;
        							}
        							vm.countBill();
        							break;
        						}
        					}
        					vm.weigh_edit_display = false;
        				}else{
        					TX.msg(json.msg,{time:5000});
        				}
        			}
        		);
        	},
        	countBill:function(){
        		var che_sum = 0;
        		var dun_sum = 0;
        		for(var i=0;i<vm.normal_report_list.length;i++){
        			if(vm.normal_report_list[i]['dataFlag'] == 1){
        				che_sum ++;
        				dun_sum += parseInt(vm.normal_report_list[i]['weigh']);
        			}
        		}
        		vm.che_sum = che_sum;
        		vm.dun_sum = dun_sum / 1000;
        	}
        });
        vm.load();
	});
	</script>
	<!--[if lt IE 9]>
	    <script src="__STATIC__/js/respond.js"></script>
	    <script src="__STATIC__/js/html5shiv.js"></script>
	    <script src="__STATIC__/js/placeholder-IE-fixes.js"></script>
	<![endif]-->
</body>
</html>